package com.example.demo;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.User;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Arrays;
import java.util.List;

@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class DemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(DemoApplication.class, args);
        UserMapper bean = run.getBeanFactory().getBean(UserMapper.class);
        List<User> users = Arrays.asList(User.builder().name("1").build(), User.builder().name("2").build());
        bean.insertList(users,"13663218177");
        users.forEach(System.out::println);
        List<User> select = bean.select();

        select.forEach(System.out::println);


    }
}
